﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master"  Inherits="System.Web.Mvc.ViewPage<ComplaintsAlertViewModel>" %>

<%--Inherits="System.Web.Mvc.ViewPage<DetailedReportViewModel>--%>


<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Complaints Alert
</asp:Content>

<asp:Content ID="ContentHeader" ContentPlaceHolderID="ContentHeader" runat="server">
Complaints Alert
</asp:Content>

<asp:Content ID="javascript" ContentPlaceHolderID="Javascript" runat="server">
 <script type="text/javascript">
     $(document).ready(function() {

         $(".faux_form :checkbox").change(function(e) {
             $(".alert").show();
             $(".success").hide();
         });

         $(".variantList :checkbox").change(function(e) {
             if ($(this).attr('checked') == true) {
                 $(this).parents('ul').siblings(".productName").children(':checkbox').attr('checked', false);
             }
         });

         $(".productName :checkbox").change(function(e) {
             if ($(this).attr('checked') == true) {
                 $(this).parent().siblings(".variantList").find(':checkbox').attr('checked', false);
             }
         });

         var tabApi = $("#accordion").tabs("ul.productHolder ", { tabs: 'h4', effect: 'slide', initialIndex: null }).data("tabs");
         //alert(tabApi.getCurrentTab());
         //$("#accordion").tabs("ul.productHolder ", { tabs: 'h4', effect: 'slide', initialIndex: 1 });
         //var tabApi= $("#accordion").data("tabs");

         $("h4").click(function() {
             
             if ($(this).hasClass("current")) {
                 //alert($(this));
                 $(this).next('ul').hide();

             }
         });


         //             }
         //         });

         //         $("h4.current").click(function() {
         //            $(this).next('ul').hide('fast', function() {
         //                     alert('Animation complete.');
         //                     //$(this).siblings('h4.current').removeClass("current");
         //            });




         //alert(tabApi.getIndex());

     });
</script>
    <style>
    /* root element for accordion. decorated with rounded borders and gradient background image */
#accordion {
}

/* accordion header */
#accordion h4 {
	cursor:pointer;		
	padding:5px;
	border-top:1px solid;
	font-weight:bold;
	font-size:1.3em;
}

/* currently active header */
#accordion h4.current {
	cursor:default;
	background-color:#EFEFEF;
}

/* accordion pane */
#accordion ul.productHolder {
	
	display:none;

}

div.productName{
    margin: 5px 0 0;
    padding: 0 0 5px;
    border:0 none;
    }
    </style>

</asp:Content>

<asp:Content ID="ContentSubNav" ContentPlaceHolderID="ContentSubNav" runat="server">
    <li class=""><%= Html.ActionLink("Create Enquiry", "Create", "Enquiry")%></li>
    <li class=""><%= Html.ActionLink("Open Enquiries", "Index", "Enquiry")%></li>
    <li class=""><%= Html.ActionLink("Completed Enquiries", "Completed", "Enquiry")%></li>
    <%--<li class=""><%= Html.ActionLink("Pending Compensation", "Pending", "Enquiry")%></li>--%>
    <li class=""><%= Html.ActionLink("Approved Compensation", "Approved", "Enquiry")%></li>
    <li class=""><%= Html.ActionLink("Declined Compensation", "Declined", "Enquiry")%></li>
    <li class="selected"><%= Html.ActionLink("Complaints Alert", "ComplaintsAlert", "Enquiry")%></li>
   
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <p>Select either Products or Categories to receive an alert email.</p>
    <div class="alert">Changes not saved yet!</div>
    <% if(TempData["Saved"] as bool? == true){ %>   
        <div class="success">Save Successful!</div>
    <% } %>
    
    <div class="faux_form" style="width:auto">
    <% using(Html.BeginForm()){ %>
    <div id="accordion">
        <%--<ul class="category">--%>
        <% foreach(var category in Model.Categories.Keys){ %>
            <%--<li class="clearfix">--%>
                <h4><%= category.Name %></h4>
                <ul class="productHolder clearfix">

                <% foreach(var product in Model.Categories[category].Keys){
                       var chkProduct = Model.Contains(product);
                       %>
                        
                        <li>
                            <div class="clearfix productName">
                                
                                <input class="chk" type="checkbox" id="variant_<%= product.DrillDownId %>" name="variantIDs" value="<%= product.DrillDownId %>" <%= chkProduct ? "checked=\"checked\"" : "" %> />
                                <label for="variant_<%= product.DrillDownId %>"><%= product.Name %></label>
                            </div>
                            
                            <ul class="clearfix variantList ">
                                <%foreach(var variant in Model.Categories[category][product]) {
                                    var chk = Model.Contains(variant);
                                      %>
                                <li>
                                    <input class="chk" type="checkbox" id="variant_<%= variant.DrillDownId %>" name="variantIDs" value="<%= variant.DrillDownId %>" <%= chk ? "checked=\"checked\"" : "" %> />
                                    <label for="variant_<%= variant.DrillDownId %>"><%= variant.Name %></label>
                                </li>
                                
                                <%
                                }
                               %>
                            </ul>
                        </li>
                
                <% } %>
                </ul>
            <%--</li>--%>
            <% } %>
        <%--</ul>--%>
        <input type="submit" title="Save" value="Save" />
        <% } %>
    </div>
 </div>
</asp:Content>

